import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
//导入组件
import Layout from '../views/layout/Layout.vue'
import Login from '../views/login/Login.vue'
import Home from '../views/home/Home.vue'

const routes = [
  {
    path:'/',
    component:Layout,
    redirect:'/home',
    children:[
        {
          path:'/home',
          name:'home',
          component:Home
        },
        {
          path:'/hot',
          name:'hot',
          component:()=>import('../views/hot/HotMusic.vue')
        },
        {
          path:'/search',
          name:'search',
          component:()=>import('../views/search/Search.vue')
        }
    ]
  },
  {
    path:'/login',
    component:Login
  },
  {
    path:'/music-list/:id',//动态路由 $route.params
    component:()=>import('../views/home/MusicList.vue'),
    props:true
  },
  {
    path:'/songUrl/:id',//动态路由 $route.params
    component:()=>import('../views/song/SongMusic.vue'),
    props:true
  },
]

const router = new VueRouter({
  routes
})

export default router
